from xlrd import open_workbook
import os
from frame_work .setting import base_Dir
xls_name = 'buyer_data.xlsx'
sheet_name = 'account'


def get_sheet():
    """
    返回一个sheet
    :return:
    """
    xls_path = os.path.join(base_Dir, "data", xls_name)
    file = open_workbook(xls_path)
    sheet = file.sheet_by_name(sheet_name)
    return sheet


def get_data(nums):
    """
    返回sheet中所有行数据，list形式
    :param nums:
    :return:
    """
    sheet = get_sheet()
    data = []
    for num in range(1, nums + 1):
        value = sheet.cell(num, 1).value
        data.append(value)
        num += 1
    return data


def get_data1(cls_num, nums):
    sheet = get_sheet()
    data = sheet.col_values(cls_num)[:nums + 1]
    data.pop(0)
    return data


def get_all_data(cls_num):
    """
    返回xls中某一列数据，并删除第一个值
    :param cls_num:
    :return:
    """
    sheet = get_sheet()
    data = sheet.col_values(cls_num)
    data.pop(0)
    return data


if __name__ == '__main__':
    # data = get_data(20,'buyer_data2.xlsx','account')
    get_all_data(2)
